<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        
        (function(window) {
            let p1 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('p1')
                }, 500)
            })
            let p2 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve('p2')
                }, 1000)
            })
            let p3 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    reject('error')
                }, 1500)
            })
            // race 谁先运行完谁输出  其余也会运行，但不输出
            Promise.race([p1, p2, p3])
                .then(res => {
                    console.log(res);
                })
                .catch(err => {
                    console.log(err);
                })
            Promise.all([p1, p2])
            .then(res => {
                console.log(res);
            })
            .catch(err => {
                console.log(err);
            })
            Promise.allSettled([p1, p2])
            .then(res => {
                console.log(res);
            })
            .catch(err => {
                console.log(err);
            })
        })(window)
    </script>
</body>
</html>